//////////////////////////////////////////////////////////////////////////////
// Product: QF/C++
// Last Updated for Version: 3.4.00
// Date of the Last Update:  Sep 01, 2007
//
//                    Q u a n t u m     L e a P s
//                    ---------------------------
//                    innovating embedded systems
//
// Copyright (C) 2002-2007 Quantum Leaps, LLC. All rights reserved.
//
// This software may be distributed and modified under the terms of the GNU
// General Public License version 2 (GPL) as published by the Free Software
// Foundation and appearing in the file GPL.TXT included in the packaging of
// this file. Please note that GPL Section 2[b] requires that all works based
// on this software must also be made publicly available under the terms of
// the GPL ("Copyleft").
//
// Alternatively, this software may be distributed and modified under the
// terms of Quantum Leaps commercial licenses, which expressly supersede
// the GPL and are specifically designed for licensees interested in
// retaining the proprietary status of their code.
//
// Contact information:
// Quantum Leaps Web site:  http://www.quantum-leaps.com
// e-mail:                  info@quantum-leaps.com
//////////////////////////////////////////////////////////////////////////////
#ifndef qsched_h
#define qsched_h

/// \ingroup qf
/// \file qsched.h
/// \brief platform-independent interface to the non-preemptive scheduler.
///
/// This header file must be included in all "vanilla" QF ports to
/// "bare metal" target boards.

                               // Vanilla QF port event queue and thread types
#define QF_EQUEUE_TYPE              QEQueue
#define QF_OS_OBJECT_TYPE           uint8_t
#define QF_THREAD_TYPE              uint8_t

             // Vanilla QF/C port scheduler locking/unlocking -- not necessary
#define QF_SCHED_LOCK()             ((void)0)
#define QF_SCHED_UNLOCK()           ((void)0)

                                              // native event queue operations
#define QACTIVE_OSOBJECT_WAIT_(me_) \
    Q_ASSERT((me_)->eQueue_.frontEvt_ != (QEvent *)0)

#define QACTIVE_OSOBJECT_SIGNAL_(me_) \
    QF_readySet_.insert((me_)->prio_); \
    QF_INT_UNLOCK_()

#define QACTIVE_OSOBJECT_ONIDLE_(me_) \
    QF_readySet_.remove((me_)->prio_)

                                            // native QF event pool operations
#define QF_EPOOL_TYPE_              QMPool
#define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \
    (p_).init(poolSto_, poolSize_, evtSize_)
#define QF_EPOOL_EVENT_SIZE_(p_)    ((p_).getBlockSize())
#define QF_EPOOL_GET_(p_, e_)       ((e_) = (QEvent *)(p_).get())
#define QF_EPOOL_PUT_(p_, e_)       ((p_).put(e_))

class QPSet;                                            // forward declaration
extern QPSet QF_readySet_;                 ///< QF-ready set of active objects

#endif                                                             // qsched_h
